package com.liruo.srpingframework.dataaccess.transaction.customize;

import com.liruo.srpingframework.dataaccess.transaction.TransactionEntity;
import com.liruo.srpingframework.dataaccess.transaction.TransactionEntityRepository;
import javax.annotation.Resource;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PrivateService {
  @Resource
  private TransactionEntityRepository repository;

  public void callPrivateTransactionalMethod(){
    ((PrivateService) AopContext.currentProxy()).privateTransactionMethod();
  }
  @Transactional
  void privateTransactionMethod(){
    repository.save(new TransactionEntity(null, "privateTransactionMethod"));
    throw new RuntimeException("privateTransactionMethod");
  }
}
